﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" 
    xmlns:menu="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
	xmlns:local="clr-namespace:Rawr.UI"
	mc:Ignorable="d"
	Width="365" Height="500"
	x:Class="Rawr.UI.ItemListControl">

	<UserControl.Resources>
		<ItemsPanelTemplate x:Key="ItemsPanelTemplateGemsRatings">
			<StackPanel Orientation="Horizontal"/>
		</ItemsPanelTemplate>
		<DataTemplate x:Key="DataTemplateGems">
			<Grid Background="{Binding SocketBrush}" Margin="1" VerticalAlignment="Center">
				<Image Source="{Binding GemIcon}" Width="24" Height="24" Margin="1"/>
			</Grid>
		</DataTemplate>
		<DataTemplate x:Key="DataTemplateRatings">
			<Rectangle VerticalAlignment="Stretch"
				Fill="{Binding Brush}"
				Visibility="{Binding Visibility}"
				Width="{Binding Width}"/>
		</DataTemplate>
		<DataTemplate x:Key="DataTemplateListBoxItemsItem">
			<Grid>
				<StackPanel Orientation="Vertical" IsHitTestVisible="False">
					<controls:DockPanel HorizontalAlignment="Stretch" LastChildFill="True">
						<Image controls:DockPanel.Dock="Left" Source="{Binding Icon}"
					   MaxHeight="32" MaxWidth="32" Margin="0,0,2,0" />
						<ItemsControl controls:DockPanel.Dock="Right" ItemsSource="{Binding Gems}"
							ItemsPanel="{StaticResource ItemsPanelTemplateGemsRatings}"
							ItemTemplate="{StaticResource DataTemplateGems}">
						</ItemsControl>
						<TextBlock VerticalAlignment="Center" HorizontalAlignment="Stretch"
						TextWrapping="Wrap" Text="{Binding Name}" Margin="1"/>
					</controls:DockPanel>
					<ItemsControl ItemsSource="{Binding Ratings}" Height="2" Margin="0,2,0,0" HorizontalAlignment="Stretch"
							ItemsPanel="{StaticResource ItemsPanelTemplateGemsRatings}"
							ItemTemplate="{StaticResource DataTemplateRatings}">
					</ItemsControl>
				</StackPanel>
                <Rectangle MouseEnter="item_MouseEnter" MouseLeave="item_MouseLeave" MouseLeftButtonUp="item_Clicked" MouseRightButtonUp="Rectangle_MouseRightButtonUp" 
					 HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
					 Fill="Transparent" Margin="-2">
                    <menu:ContextMenuService.ContextMenu>
                        <menu:ContextMenu x:Name="ContextMenuItem" Opened="ContextMenuItem_Opened">
                            <!--<menu:MenuItem x:Name="ContextItemName" IsEnabled="False" Header="Super Cool Item"/>
                            <menu:Separator/>-->
                            <menu:MenuItem x:Name="ContextEdit" Header="Edit..." Click="EditItem"/>
                            <menu:MenuItem x:Name="ContextOpenWowhead" Header="Open in Wowhead" Click="OpenInWowhead"/>
                            <!--<menu:MenuItem x:Name="ContextRefreshArmory" Header="Refresh Item from Armory" Click="RefreshItemFromArmory" Visibility="Collapsed"/>-->
                            <menu:MenuItem x:Name="ContextRefreshWowhead" Header="Refresh Item from Wowhead" Click="RefreshItemFromWowhead"/>
                            <!--<menu:MenuItem x:Name="ContextEquip" Header="Equip" Click="EquipItem"/>-->
                            <!--<menu:MenuItem x:Name="ContextAddCustom" Header="Add Custom Gemming..." Click="AddCustomGemming" Visibility="Collapsed"/>-->
                            <!--<menu:MenuItem x:Name="ContextDeleteCustom" Header="Delete Custom Gemming" Click="DeleteCustomGemming" Visibility="Collapsed"/>-->
                            <!--<menu:MenuItem x:Name="ContextEvaluateUpgrade" Header="Evaluate Upgrade..." Click="EvaluateUpgrade"/>-->
                            <!--<menu:MenuItem x:Name="ContextEvaluateUpgradesBySlot" Header="Evaluate Upgrades for this Slot..." Click="EvaluateUpgradesbySlot"/>-->
                            <!--<menu:MenuItem x:Name="ContextRemoveItemFromUpgradeList" Header="Remove Item from Upgrade List" Click="ContextRemoveItemFromUpgradeList_Click"/>-->
                        </menu:ContextMenu>
                    </menu:ContextMenuService.ContextMenu>
                </Rectangle>
            </Grid>
		</DataTemplate>
	</UserControl.Resources>
	
  <Grid Background="#00000000" Margin="-10000,-10000,-10000,-10000" IsHitTestVisible="True" MouseLeftButtonDown="Background_MouseLeftButtonDown">
	<Border Margin="10000,10000,10000,10000" BorderBrush="DarkGray" BorderThickness="1" CornerRadius="2">
	  <Grid>
		<Grid.RowDefinitions>
		  <RowDefinition Height="26"/>
		  <RowDefinition/>
		</Grid.RowDefinitions>
		<controls:DockPanel LastChildFill="True">
		  <controls:DockPanel.Background>
			<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
			  <GradientStop Color="#FFDEDEDE" Offset="1"/>
			  <GradientStop Color="#FFFFFFFF" Offset="0"/>
			</LinearGradientBrush>
		  </controls:DockPanel.Background>
		  <TextBlock controls:DockPanel.Dock="Left" VerticalAlignment="Center" Margin="4,2,2,2" Text="Filter: " />
		  <ComboBox x:Name="comboBoxSort" controls:DockPanel.Dock="Right" VerticalAlignment="Center" Margin="2" SelectionChanged="comboBoxSort_SelectionChanged" />
		  <TextBlock controls:DockPanel.Dock="Right" VerticalAlignment="Center" Margin="2,2,6,2" Text="Sort: " />
		  <TextBox x:Name="textBoxFilter" Text="{Binding Path=Items.Filter, Mode=TwoWay}" TextChanged="Filter_TextChanged" VerticalAlignment="Center" Margin="2" />
		</controls:DockPanel>
		<ListBox Grid.Row="1" x:Name="listBoxItems" BorderThickness="0" ItemTemplate="{StaticResource DataTemplateListBoxItemsItem}"
		   ItemsSource="{Binding Items}" ScrollViewer.VerticalScrollBarVisibility="Visible"
		   SelectionChanged="listBoxItems_SelectionChanged" MouseWheel="listBoxItems_MouseWheel">
		  <ListBox.ItemContainerStyle>
			<Style TargetType="ContentControl">
			  <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
			  <Setter Property="MaxWidth" Value="344"/>
			</Style>
		  </ListBox.ItemContainerStyle>
		</ListBox>
	  </Grid>
	</Border>
  </Grid>
</UserControl>